Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.pvzChannelOppo = undefined;
var $2pvzChannelWeb = require("pvzChannelWeb");
var $2kc = require("kc");
exports.pvzChannelOppo = /* */function (_n$pvzChannelWeb2) {
  babel_inherits(_class9, _n$pvzChannelWeb2);
  var _super111 = babel_createSuper(_class9);
  function _class9() {
    var _this263;
    babel_classCallCheck(this, _class9);
    _this263 = _super111.apply(this, arguments);
    _this263.channel = "oppo";
    _this263.paraMap = new Map([["bannerAd", "733834"], ["nativeBannerAd", "733906"], ["nativeInsertAd", "733890"], ["nativeInsertAd2", "733905"], ["vedioAd", "733908"], ["gird9", "733915"], ["nativeIcon", "733882"], ["nativeIcon2", "733889"], ["ctrlId", "63c67586f9d13c5453ed06ad"], ["gid", "63d7a9d4f9d13c5453eef498"]]);
    _this263.channelObj = window.qg;
    _this263.gird9CallMap = {};
    _this263.bannerTimeId = -1;
    _this263.nativePrefabMap = {
      nativeBannerAd: "nativeBanner",
      nativeInsertAd: "nativeInter",
      nativeInsertAd2: "nativeInter",
      nativeIcon: "nativeIcon",
      nativeIcon2: "nativeIcon"
    };
    return _this263;
  }
  babel_createClass(_class9, [{
    key: "getSysInfo",
    value: function getSysInfo() {
      this.sysInfo || (this.sysInfo = this.channelObj.getSystemInfoSync());
      return this.sysInfo;
    }
  }, {
    key: "exit",
    value: function exit() {
      this.channelObj.exitApplication({
        data: 0
      });
    }
  }, {
    key: "init",
    value: function init() {
      var _this264 = this;
      babel_get(babel_getPrototypeOf(_class9.prototype), "init", this).call(this);
      var e = {
        id: this.getPara("ctrlId")
      };
      $2kc.default.jpost("https://ga.gametdd.com/adCtrl/agd/conf", e, function (e, t) {
        if (e) {
          $2kc.default.err(e);
        } else if ("" + t.code == "0") {
          _this264.ctrl = t.data;
          $2kc.default.log("返回", _this264.ctrl);
        } else {
          $2kc.default.err("返回值错误:" + JSON.stringify(t));
        }
      });
    }
  }, {
    key: "hasPrivacy",
    value: function hasPrivacy() {
      return true;
    }
  }, {
    key: "showVideo",
    value: function showVideo(e) {
      var _this265 = this;
      $2kc.default.log("showVideo", this.getPara("vedioAd"), this.rewardedVideoAd);
      this.rewardedVideoAd = this.channelObj.createRewardedVideoAd({
        adUnitId: this.getPara("vedioAd")
      });
      this.videoFns.onLoad && this.rewardedVideoAd.offLoad(this.videoFns.onLoad);
      this.videoFns.onError && this.rewardedVideoAd.offError(this.videoFns.onError);
      this.videoFns.onClose && this.rewardedVideoAd.offClose(this.videoFns.onClose);
      this.rewardedVideoAd.offLoad();
      this.rewardedVideoAd.offError();
      this.rewardedVideoAd.offClose();
      var t = this;
      this.videoFns.onLoad = function () {
        $2kc.default.log("激励视频 广告加载成功");
        t.rewardedVideoAd.show().then(function () {
          $2kc.default.log("激励视频 广告显示");
        }).catch(function (e) {
          $2kc.default.err(e);
        });
      };
      this.videoFns.onError = function (t) {
        $2kc.default.err(t);
        e.failCall();
        _this265.channelObj.showToast({
          title: "暂无广告"
        });
      };
      this.videoFns.onClose = function (t) {
        t && t.isEnded && e.sucCall();
        e.endCall();
      };
      this.rewardedVideoAd.onLoad(this.videoFns.onLoad);
      this.rewardedVideoAd.onError(this.videoFns.onError);
      this.rewardedVideoAd.onClose(this.videoFns.onClose);
      this.rewardedVideoAd.load();
    }
  }, {
    key: "addGird9Icon",
    value: function addGird9Icon(e, t) {}
  }, {
    key: "gird9IconClick",
    value: function gird9IconClick() {
      var _this266 = this;
      $2kc.default.log("gird9IconClick", this.getPara("gird9"), this.boxPortalAd);
      var e = this.channelObj;
      if (e.createGamePortalAd) {
        this.gird9CallMap.onLoad && this.boxPortalAd.offLoad(this.gird9CallMap.onLoad);
        this.boxPortalAd = e.createGamePortalAd({
          adUnitId: this.getPara("gird9")
        });
        this.boxPortalAd.offLoad();
        this.boxPortalAd.offError();
        this.boxPortalAd.onError(function (e) {
          $2kc.default.log("盒子九宫格广告加载失败" + JSON.stringify(e));
        });
        this.gird9CallMap.onLoad = function () {
          _this266.boxPortalAd.show().then(function () {
            $2kc.default.log("九宫格show success");
          }).catch(function (e) {
            $2kc.default.err("九宫格show失败" + JSON.stringify(e));
          });
        };
        this.boxPortalAd.onLoad(this.gird9CallMap.onLoad);
        this.boxPortalAd.load();
      } else {
        $2kc.default.log("暂不支持互推盒子相关 API");
      }
    }
  }, {
    key: "closeGird9",
    value: function closeGird9() {
      if (null != this.boxPortalAd) {
        this.boxPortalAd.isDestroyed = true;
        this.boxPortalAd.destroy();
      }
    }
  }, {
    key: "showBanner",
    value: function showBanner(e, t, a) {
      var n = {
        adUnitId: this.getPara("bannerAd")
      };
      this.bannerAd = this.channelObj.createBannerAd(n);
      this.bannerAd.onError(function (e) {
        $2kc.default.log("banner广告加载失败" + JSON.stringify(e));
      });
      this.bannerAd.show().then(function () {
        $2kc.default.log("banner广告展示完成");
      }).catch(function (e) {
        $2kc.default.log("banner广告展示失败" + JSON.stringify(e));
      });
    }
  }, {
    key: "closeBanner",
    value: function closeBanner() {
      this.bannerAd && this.bannerAd.hide();
    }
  }, {
    key: "showBannerByTime",
    value: function showBannerByTime() {
      var _this267 = this;
      var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      var t = 30;
      this.bannerTimeId >= 0 && clearInterval(this.bannerTimeId);
      this.closeBanner();
      t < 30 && (t = 30);
      this.showBanner(e, null, "battle");
      this.bannerTimeId = setInterval(function () {
        _this267.showBanner(e, null, "battle");
      }, 1e3 * t);
    }
  }, {
    key: "closeBannerByTime",
    value: function closeBannerByTime() {
      this.bannerTimeId >= 0 && clearInterval(this.bannerTimeId);
      this.closeBanner();
    }
  }, {
    key: "showNative",
    value: function showNative(e, t, a, n, i) {}
  }, {
    key: "checkNativeInsert",
    value: function checkNativeInsert(e) {
      if (e.indexOf("Insert") > 0 && this.nativeNodeMap[e] && this.nativeNodeMap[e].active) {
        if (this.nativeNodeMap.nativeInsertAd && this.nativeNodeMap.nativeInsertAd.active) {
          $2kc.default.log("原生插屏只能出一个");
          return false;
        }
        if (this.nativeNodeMap.nativeInsertAd2 && this.nativeNodeMap.nativeInsertAd2.active) {
          $2kc.default.log("原生插屏只能出一个2");
          return false;
        }
      }
      return true;
    }
  }, {
    key: "loadNative",
    value: function loadNative(e, t) {
      var a = this.channelObj;
      var n = this;
      $2kc.default.log("加载oppo原生", n.getPara(e));
      n.nativeAds[e] = a.createNativeAd({
        adUnitId: n.getPara(e)
      });
      n.nativeAdCallMap.onLoad && n.nativeAds[e].offLoad(n.nativeAdCallMap.onLoad);
      n.nativeAdCallMap.onError && n.nativeAds[e].offError(n.nativeAdCallMap.onError);
      n.nativeAds[e].offLoad();
      n.nativeAds[e].offError();
      n.nativeAdCallMap.onLoad = function (a) {
        $2kc.default.log("原生广告加载完成", e, a.adList);
        n.nativeAdListMap[e] = a.adList;
        t && t(a.adList, e);
      };
      n.nativeAdCallMap.onError = function (a) {
        $2kc.default.log("原生广告加载失败", e, a);
        if (e.indexOf("2") < 0) {
          n.closeNative(e);
          n.loadNative(e + "2", t);
        }
      };
      n.nativeAds[e].onLoad(n.nativeAdCallMap.onLoad);
      n.nativeAds[e].onError(n.nativeAdCallMap.onError);
      n.nativeAds[e].load();
    }
  }, {
    key: "loadAndShowNative",
    value: function loadAndShowNative(e, t, a) {}
  }, {
    key: "findAndReport",
    value: function findAndReport() {}
  }, {
    key: "reportAdShow",
    value: function reportAdShow(e, t) {
      $2kc.default.log("reportAdShow 开始", e);
      var a = this.nativeAds[e];
      var n = this.nativeAdListMap[e];
      if (!a || !n || n.length <= 0) {
        $2kc.default.err("reportAdShow失败", n);
      } else {
        a.reportAdShow({
          adId: n[0].adId
        });
        this.nativeNodeMap[e] = t;
      }
    }
  }, {
    key: "reportAdClick",
    value: function reportAdClick(e) {
      $2kc.default.log("reportAdClick 开始", e);
      var t = this.nativeAds[e];
      var a = this.nativeAdListMap[e];
      if (!t || !a || a.length <= 0) {
        $2kc.default.err("reportAdClick失败", a);
      } else {
        t.reportAdClick({
          adId: a[0].adId
        });
      }
    }
  }, {
    key: "closeNative",
    value: function closeNative(e) {
      $2kc.default.log("原生关闭", e);
      this.nativeAdListMap[e] = null;
      this.nativeAds[e] = null;
      var t = this.nativeNodeMap[e];
      if (t && t.active) {
        t.active = false;
        t.destroy();
      }
      this.nativeNodeMap[e] = null;
    }
  }, {
    key: "getNativeData",
    value: function getNativeData(e) {
      if (this.nativeAdListMap[e]) {
        return this.nativeAdListMap[e];
      } else {
        return null;
      }
    }
  }]);
  return _class9;
}($2pvzChannelWeb.pvzChannelWeb);